const db = require('../db/index')
const {baseURL} = require('../config')

//获取寻宠帖子的数据
exports.getNote = (req,res)=>{
  const sql =  `SELECT id, content,nickname, avatar,time,picture FROM t_notes JOIN t_users ON t_users.user_id = t_notes.user_id`
  db.query(sql, function(err, results) {
    if(err) res.send(err)
    results.forEach(item => {
      item.avatar = baseURL + item.avatar
      item.picture = baseURL + item.picture
    });
    res.send({
      status:0,
      message:'获取成功',
      data: results
    })
  
  })
}